//
//  HomeCollectionViewCell.m
//  MMLOOK
//
//  Created by dllo on 15/9/4.
//  Copyright (c) 2015年 武俊娥. All rights reserved.
//

#import "HomeCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface HomeCollectionViewCell ()

@property (nonatomic, retain) UIImageView *aimageView;
@property (nonatomic, retain) UILabel *titleLabel;

@end

@implementation HomeCollectionViewCell

- (void)dealloc
{
    [_aimageView release];
    [_titleLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self creatSubView];
    }
    return self;
}

- (void)creatSubView
{
    self.aimageView = [[UIImageView alloc] init];
    self.aimageView.layer.cornerRadius = 10;
    self.aimageView.layer.masksToBounds = YES;
    [self.contentView addSubview:_aimageView];
    [_aimageView release];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.backgroundColor = [UIColor colorWithWhite:0  alpha:0.5];
    self.titleLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.aimageView.frame = CGRectMake(5, 0, self.contentView.frame.size.width - 10, self.contentView.frame.size.height);
    self.titleLabel.frame = CGRectMake(self.aimageView.frame.origin.x, self.aimageView.frame.size.height * 5 / 6 + self.aimageView.frame.origin.y, self.aimageView.frame.size.width, self.aimageView.frame.size.height / 6);
}

- (void)sendDic: (NSMutableDictionary *)dic
{
    [self.aimageView sd_setImageWithURL:[NSURL URLWithString:[dic objectForKey:@"cover_image_url"]] placeholderImage:[UIImage imageNamed:@"home.jpg"]];
    self.titleLabel.text = [NSString stringWithFormat:@"  %@", [dic objectForKey:@"title"]];
}

@end
